package com.stormrage.edu.serv.exam.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.stormrage.edu.dao.exam.ExmStudentAnswerDao;
import com.stormrage.edu.serv.exam.ExmStudentAnswerServ;
import com.stormrage.entity.exam.ExmStudentAnswer;
import com.stormrage.entity.exam.rep.ExmStudentAnswerRep;
import com.stormrage.entity.exam.req.ExmStudentAnswerReq;
import com.stormragetech.core.exception.StormrageTechException;

/**
 * @Title: ExmStudentExamDaoImpl.java
 * @Package com.stormrage.edu.dao.exam.impl
 * @Description: 学员考试试题答案 Service
 * @author www.stormragetech.com
 * @date 2016年5月17日
 * @version V1.0
 */
@Service
public class ExmStudentAnswerServImpl implements ExmStudentAnswerServ {

	private static final Logger logger = LoggerFactory.getLogger(ExmStudentAnswerServImpl.class);

	@Autowired
	private ExmStudentAnswerDao exmStudentAnswerDao;

	@Override
	public Integer create(final ExmStudentAnswer arg0) throws StormrageTechException {

		logger.debug(" 【 Serv 】- 【 ExmStudentExamServ 】- 【 create 】-【 STARTED 】");

		Integer index = exmStudentAnswerDao.create(arg0);

		logger.debug(" 【 Serv 】- 【 ExmStudentExamServ 】- 【 create 】-【 COMPLETED 】");
		return index;

	}

	@Override
	public void delete(final Integer arg0) throws StormrageTechException {

		logger.debug(" 【 Serv 】- 【 ExmStudentExamServ 】- 【 delete 】-【 STARTED 】");

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("id", arg0);

		exmStudentAnswerDao.delete(map);

		logger.debug(" 【 Serv 】- 【 ExmStudentExamServ 】- 【 delete 】-【 COMPLETED 】");

	}

	@Override
	public List<ExmStudentAnswer> queryByExamId(final Integer arg0) throws StormrageTechException {

		logger.debug(" 【 Serv 】- 【 ExmStudentExamServ 】- 【 queryRepListByStuId 】-【 STARTED 】");

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("id", arg0);

		List<ExmStudentAnswer> array = exmStudentAnswerDao.queryByExamId(map);

		logger.debug(" 【 Serv 】- 【 ExmStudentExamServ 】- 【 queryRepListByStuId 】-【 COMPLETED 】");
		return array;

	}

	@Override
	public List<ExmStudentAnswerRep> queryRepByExamId(final Integer arg0) throws StormrageTechException {

		logger.debug(" 【 Serv 】- 【 ExmStudentExamServ 】- 【 queryRepByExamId 】-【 STARTED 】");

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("id", arg0);

		List<ExmStudentAnswerRep> array = exmStudentAnswerDao.queryRepByExamId(map);

		logger.debug(" 【 Serv 】- 【 ExmStudentExamServ 】- 【 queryRepByExamId 】-【 COMPLETED 】");
		return array;

	}

	@Override
	public List<ExmStudentAnswerRep> queryRepByExamCorr(final ExmStudentAnswerReq arg0) throws StormrageTechException {

		logger.debug(" 【 Serv 】- 【 ExmStudentExamServ 】- 【 queryRepByExamCorr 】-【 STARTED 】");

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("id", arg0.getExamId());
		map.put("correct", arg0.getCorrect());

		List<ExmStudentAnswerRep> array = exmStudentAnswerDao.queryRepByExamCorr(map);

		logger.debug(" 【 Serv 】- 【 ExmStudentExamServ 】- 【 queryRepByExamCorr 】-【 COMPLETED 】");
		return array;

	}

}
